package com.vimaltuts.mycontacts;

import com.vimaltuts.mycontacts.R;

import android.app.Activity;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class ViewContact extends Activity {

	private TextView name;
	private TextView phone;
	private TextView mail;
	private TextView fb;
	private ImageView photo;
	private Button backBtn;
	private byte[] image;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.view_contact);
		setUpViews();
	}

	private void setUpViews() {
		name = (TextView) findViewById(R.id.add_name);
		phone = (TextView) findViewById(R.id.add_phone);
		mail = (TextView) findViewById(R.id.add_email);
		fb = (TextView) findViewById(R.id.add_fb);
		photo = (ImageView) findViewById(R.id.photo);
		
		
		Bundle extras = getIntent().getExtras();

		if (extras != null) {
			name.setText(extras.getString("name"));
			phone.setText(extras.getString("phone"));
			mail.setText(extras.getString("email"));
			fb.setText(extras.getString("fb"));
			image = extras.getByteArray("blob");

			if (image != null) {
				if (image.length > 3) {
					photo.setImageBitmap(BitmapFactory.decodeByteArray(image,0,image.length));
				}
			}
			
		}
		
		backBtn=(Button)findViewById(R.id.back);
		backBtn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		
	}

}
